﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace NJ.Models
{
    public partial class NJContext : DbContext
    {
        public NJContext()
        {
        }

        //public NJContext(DbContextOptions<NJContext> options)
        //    : base(options)
        //{
        //}

        public virtual DbSet<Jparmy> Jparmy { get; set; }
        public virtual DbSet<Progress> Progress { get; set; }
        public virtual DbSet<Safe> Safe { get; set; }
        public virtual DbSet<Survivor> Survivor { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer("Data Source = localhost; Initial Catalog = NJ; Persist Security Info = True; User ID = sa; Password = szy1219/*-+");
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Jparmy>(entity =>
            {
                entity.ToTable("jparmy");

                entity.Property(e => e.Id).HasColumnName("ID");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasColumnName("name")
                    .HasMaxLength(50);
            });

            modelBuilder.Entity<Progress>(entity =>
            {
                entity.ToTable("progress");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .ValueGeneratedNever();

                entity.Property(e => e.Army).HasColumnName("ARMY");

                entity.Property(e => e.Detail).HasColumnName("DETAIL");

                entity.Property(e => e.Name)
                    .HasColumnName("NAME")
                    .HasMaxLength(255);

                entity.Property(e => e.Number).HasColumnName("NUMBER");

                entity.Property(e => e.Surviver).HasColumnName("SURVIVER");

                entity.Property(e => e.Time)
                    .HasColumnName("TIME")
                    .HasColumnType("date");

                entity.Property(e => e.Timeno).HasColumnName("TIMENO");
            });

            modelBuilder.Entity<Safe>(entity =>
            {
                entity.ToTable("safe");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .ValueGeneratedNever();

                entity.Property(e => e.Army).HasColumnName("ARMY");

                entity.Property(e => e.Detail).HasColumnName("DETAIL");

                entity.Property(e => e.Event).HasColumnName("EVENT");

                entity.Property(e => e.Location).HasColumnName("LOCATION");

                entity.Property(e => e.Name)
                    .HasColumnName("NAME")
                    .HasMaxLength(50);

                entity.Property(e => e.Othername)
                    .HasColumnName("OTHERNAME")
                    .HasMaxLength(50);

                entity.Property(e => e.Owner)
                    .HasColumnName("OWNER")
                    .HasMaxLength(50);

                entity.Property(e => e.Source).HasColumnName("SOURCE");

                entity.Property(e => e.Timeno).HasColumnName("TIMENO");
            });

            modelBuilder.Entity<Survivor>(entity =>
            {
                entity.ToTable("survivor");

                entity.Property(e => e.Id).HasColumnName("ID");

                entity.Property(e => e.Intro).HasColumnName("intro");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.Pic).HasColumnName("pic");
            });
        }
    }
}
